<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let obj = {
            a: [1, 2, 3],
            [Symbol.iterator]() {
                let arr = this.a;
                let len = this.a.length;
                let index = 0;
                return {
                    next() {
                        if (index < len) {
                            return {
                                value: arr[index++],
                                done: false
                            }
                        } else {
                            return {
                                value: arr[index++],
                                done: true
                            }
                        }
                    }
                }
            }
        }

        for (let k of obj) {
            console.log(k);
        }
    </script>
</body>

</html>